package com.ntt.benew.dictionary.entity.gpt

import android.os.Parcel
import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName

@Keep
data class StructureEntity(
    val uid: Long,
    @field:SerializedName("svoca_sentence")
    val original: String? = null,
    @field:SerializedName("svoca_sentence_translation")
    val translation: String? = null,
    @field:SerializedName("svoca_sentence_part")
    val originalStructure: SentenceStructureEntity? = null,
    @field:SerializedName("svoca_sentence_part_translation")
    val translateStructure: SentenceStructureEntity? = null,
    @field:SerializedName("major_vocabulary")
    val words: List<CoreWordEntity>? = null,
    @field:SerializedName("chunking_sentence_part")
    val chunking: List<ChunkingEntity>? = null
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readLong(),
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(SentenceStructureEntity::class.java.classLoader),
        parcel.readParcelable(SentenceStructureEntity::class.java.classLoader),
        parcel.createTypedArrayList(CoreWordEntity),
        parcel.createTypedArrayList(ChunkingEntity)
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(uid)
        parcel.writeString(original)
        parcel.writeString(translation)
        parcel.writeParcelable(originalStructure, flags)
        parcel.writeParcelable(translateStructure, flags)
        parcel.writeTypedList(words)
        parcel.writeTypedList(chunking)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<StructureEntity> {
        override fun createFromParcel(parcel: Parcel): StructureEntity {
            return StructureEntity(parcel)
        }

        override fun newArray(size: Int): Array<StructureEntity?> {
            return arrayOfNulls(size)
        }
    }
}